
<div class="myinfo-main">
  
  <div class="myinfo-right">
    <div class='myprofile'>
      <p class='title'>&nbsp;&nbsp;My Avatar</p>
      <?php $form=$this->beginWidget('CActiveForm', array(
            'id'=>'product-form',
            // Please note: When you enable ajax validation, make sure the corresponding
            // controller action is handling ajax validation correctly.
            // There is a call to performAjaxValidation() commented in generated controller code.
            // See class documentation of CActiveForm for details on this.
            'enableAjaxValidation'=>false,
    )); ?>
      <p class='title myavatar' value="1"><img src="<?php echo $imgpath?>" width="100" height="100" id="myavatar" value="1"></p>
      <ul class='info-left'>
        <li class="info-left-img">
          <?php  for($img=1;$img<=10;$img++){?>
          <a href="javascript:;" onclick=select(<?php echo $img?>)><img src="<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg<?php echo $img?>.jpg" width="62" height="62"></a>
          <?php }?>

        </li>

        <li class="info-left-img">
          <?php  for($img=1;$img<=10;$img++){?>
          <a href="javascript:;" onclick=select(<?php echo $img+10?>)><img src="<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg<?php echo $img+10?>.jpg" width="62" height="62"></a>
          <?php }?>
        </li>
        <li class="info-left-img">
          <?php  for($img=1;$img<=10;$img++){?>
          <a href="javascript:;" onclick=select(<?php echo $img+20?>)><img src="<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg<?php echo $img+20?>.jpg" width="62" height="62"></a>
          <?php }?>
        </li>
        <li class="info-left-img">
          <?php  for($img=1;$img<=10;$img++){?>
          <a href="javascript:;" onclick=select(<?php echo $img+30?>)><img src="<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg<?php echo $img+30?>.jpg" width="62" height="62"></a>
          <?php }?>
        </li>
        <li class="info-left-img">
          <?php  for($img=1;$img<=2;$img++){?>
          <a href="javascript:;" onclick=select(<?php echo $img+40?>)><img src="<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg<?php echo $img+40?>.jpg" width="62" height="62"></a>
          <?php }?>
        </li>
        
          <?php $this->endWidget(); ?>
      </ul>
      <p class="avater-but"><button class="btn btn-bid-auction" onclick=update()>confirm</button></p>
      

    </div>
  </div>
</div>
<script type="text/javascript">
function select(num){
  $("#myavatar").attr('src',"<?php echo Yii::app()->resource->path('')?>/images/avatar/headimg"+num+".jpg");
  $(".myavatar").attr('value',num);
}
function update(){
  var img_num=$(".myavatar").attr('value');
  $.post('<?php echo Yii::app()->resource->path('')?>/myaccount/ajaxavatar',{'img_num':img_num},function(data){
    alert(data);
  })
}
</script>